package com.chis.childcheck;

import com.alibaba.fastjson.JSON;
import com.chis.jm.bean.ChildSynInfoBean;
import com.chis.jm.bean.CrTriggerBean;
import com.chis.jm.bean.TriggerBean;
import com.chis.jm.bean.jxc.trace.TraceBean;
import com.chis.jmdataspark.comm.JedisSerializeUtil;
import redis.clients.jedis.ShardedJedis;

import java.util.Set;

/**
 * 
 * @Description 
 * @Company zwx
 * @author wlj
 * @version 2019年08月30日
 */
public class DelExc {

    public static void main(String[] args) {
        String opt = args[0];
        String key = args[1];
        Double score = Double.valueOf(args[2]);
        ShardedJedis jedis = JedisConnect.getInstance().sparkjedisPool.getResource();
        jedis.select(1);
        Set<byte[]> value = jedis.zrangeByScore(key.getBytes(),score,score+1);
        for(byte[] serVal : value){
            if(opt.equals("1")){
                if(key.contains("TOPIC_GM") || key.contains("TOPIC_SRV")){
                    TriggerBean triggerBean = (TriggerBean) JedisSerializeUtil.unserialize(serVal);
                    System.out.println(JSON.toJSONString(triggerBean));
                }else if (key.contains("TOPIC_UPINFO")){
                    ChildSynInfoBean childSynInfoBeanTemp = (ChildSynInfoBean) JedisSerializeUtil.unserialize(serVal);
                    System.out.println(JSON.toJSONString(childSynInfoBeanTemp));
                }else if (key.contains("TOPIC_CRGM")){
                    CrTriggerBean crTriggerBean = (CrTriggerBean) JedisSerializeUtil.unserialize(serVal);
                    System.out.println(JSON.toJSONString(crTriggerBean));
                }else if (key.contains("TOPIC_TRACE")){
                    TraceBean traceBean = (TraceBean) JedisSerializeUtil.unserialize(serVal);
                    System.out.println(JSON.toJSONString(traceBean));
                }
            } else if(opt.equals("2")) {
                jedis.zrem(key.getBytes(), serVal);
            }
        }


    }
}
